package com.ruoyi.framework.interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Component
public class ContentLengthInterceptor implements HandlerInterceptor {

    private final static Logger logger = LoggerFactory.getLogger(ContentLengthInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        String contentLengthHeader = request.getHeader("Content-Length");
        if (contentLengthHeader != null) {
            logger.info("Request="+request.getRequestURL()+" ，Content-Length: " + contentLengthHeader);
        }
        return true;
    }
}